<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <%--<link rel="stylesheet" href="/ztree/css/demo.css" type="text/css">--%>
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css">
    <script type="text/javascript" src="/ztree/js/jquery-1.4.4.min.js"></script>
    <script type="text/javascript" src="/ztree/js/jquery.ztree.core.js"></script>
    <script type="text/javascript" src="/ztree/js/jquery.ztree.excheck.js"></script>

    <script type="text/javascript">
        var setting = {
            async: {
                enable: true,
                url: "/role/totree"
            },
            check: {
                enable: true,
                chkStyle: "checkbox",
                chkboxType: {"Y": "ps", "N": "ps"}
            },
            data: {
                simpleData: {
                    enable: true
                }
            },
            callback: {
                onAsyncSuccess: zTreeOnAsyncSuccess
            }
        }

        function zTreeOnAsyncSuccess() {
            var zTree = $.fn.zTree.getZTreeObj("treeRole");
            var nodeList = zTree.getNodes();
            for (i = 0; i < 3; i++) {
                zTree.expandNode(nodeList[i], true);
            }
        }

        function updateTree() {
            var zTree = $.fn.zTree.getZTreeObj("treeRole");
            checkCount = zTree.getCheckedNodes(true);
            var classpurview = "";
            for (var i = 0; i < checkCount.length; i++) {
                classpurview += "," + checkCount[i].path
            }
            classpurview = classpurview.substring(1);
            $("#opath").val(classpurview);
            $("#authform").submit();
        }

        $(document).ready(function () {
            $.fn.zTree.init($("#treeRole"), setting);
        });
    </script>
</head>
<body>
<div style="margin: 15px 40px 0px 40px;border: 1px solid;border-color:#cecece;height:92%;overflow:auto">
    <div style="width: 23%;height: 100%;border-right: 1px solid;border-color:#cecece;float: left;background-color: #F2F2F2">
        <div style="margin-top: 100px;text-align: center">
            <div style="font-size:14px;color: #393939;margin-bottom:5px">资源授权：</div>
            <div style="font-size:14px;color: #393939">${role.oname}</div>
            <button type="button" class="layui-btn" style="margin-top: 250px" onclick="updateTree();">提交</button>
        </div>
        <form id="authform" method="post" action="/role/auth">
            <input id="hiddenoid" type="hidden" name="oid" value="${role.oid}">
            <input id="opath" type="hidden" name="path">
        </form>
    </div>
    <div style="float: left;width: 71%;height: 100%">
        <ul style="margin-left:35%;margin-top: 25px" id="treeRole" class="ztree"></ul>
    </div>
</div>
</body>
</html>
